<?php
require_once "repeat.class.php";
class test{
    public function sendMail($arr){
//        ignore_user_abort(0);
//        set_time_limit(0);

        require_once "mySendMail.php";
        $mail = new MySendMail();
// $mail->setServer("smtp@126.com", "XXXXX@126.com", "XXXXX"); //设置smtp服务器，普通连接方式

//    $mail->setServer("smtp.qq.com", "2733934224@qq.com", "npsyxfeettywddic", 465, true); //设置smtp服务器，到服务器的SSL连接
        $mail->setServer("smtp.qq.com", "1966694923@qq.com", "jmvefqjqkxajbija", 465, true); //设置smtp服务器，到服务器的SSL连接
//    $mail->setFrom("2733934224@qq.com"); //设置发件人
        $mail->setFrom("1966694923@qq.com"); //设置发件人
//    $mail->setReceiver("czrll2@163.com"); //设置收件人，多个收件人，调用多次
// $mail->setCc("XXXX"); //设置抄送，多个抄送，调用多次
// $mail->setBcc("XXXXX"); //设置秘密抄送，多个秘密抄送，调用多次
//    $mail->addAttachment("../miku.jpg"); //添加附件，多个附件，调用多次
        $mail->setMail("test", "<b>test</b>"); //设置邮件主题、内容


        if(isset($arr['addAddress'])){
            $addArr=explode(',',$arr['addAddress']);
            foreach ($addArr as $v)
                $mail->setReceiver($v);
        }
        if(isset($arr['Body'])&&isset($arr['Subject']))
            $mail->setMail($arr['Subject'],$arr['Body'].date("Y-m-d H:i:s"));
        if(isset($arr['addAttachment'])){
            $addArr=explode(',',$arr['addAttachment']);
            foreach ($addArr as $v)
                $mail->addAttachment($v);
        }
        $mail->sendMail(); //发送

    }
    public function start(){
        ignore_user_abort(0);
        set_time_limit(0);

        $startTime=date("Y-m-d H:i:s");
//$startTime="2017-7-31 17:50:50";
//print_r($d);
        $temp=time();
        $mail=[
            "Subject" => "测a1",
            "Body" => "<h1>测试$temp</h1>",
            "addAddress" => "czrll2@163.com",
            "addAttachment"=>'../miku.jpg,../gundam.jpg'

        ];
//$sTime,$function,$arr,$sendInterval=60,$times=5)
        $s = new repeat($startTime,'sendMail',$mail,10,10);
        $s->start();

    }

}


$a=new test();
$a->start();